package cn.yuanqiao.activiti.listener;

import cn.yuanqiao.common.constant.SecurityConstants;
import cn.yuanqiao.common.exception.activiti.ArchiveProcessException;
import cn.yuanqiao.feignService.RemoteCommonService;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName: WritsArchiveBorrowListener
 * @Description: 类的描述
 * @author: lihuahua
 * @date: 2023/6/5 19:24
 * @Blog: huahuacoco.top
 */

@Component("ArchiveBjfbAgreeListener")
public class ArchiveBjfbAgreeListener implements ExecutionListener {


    @Autowired
    private RemoteCommonService remoteCommonService;

    @Override
    public void notify(DelegateExecution execution) {
        Object processVariables = execution.getVariable("processVariables");
        if (processVariables == null){
            throw new ArchiveProcessException("方案数据不能为空");
        }
        Map<String,Object> fanganData = (Map<String, Object>) processVariables;
        String id = String.valueOf(fanganData.get("id"));
        remoteCommonService.updateFanganState(id,"1");
        System.out.println("同意编辑发布，修改数据");
    }
}
